package pers.cl.alibaba.sentinel;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.alibaba.csp.sentinel.slots.block.BlockException;
import org.springframework.stereotype.Service;

@Service
public class HelloServiceImpl implements HelloService {

    @SentinelResource(value = "hello", fallback = "helloFallback", blockHandler = "helloBlock")
    public String hello(String name) {
        return name;
    }

    public String helloFallback(String name, Throwable t) {
        t.printStackTrace();
        return "fallback";
    }

    public String helloBlock(String name, BlockException e) {
        e.printStackTrace();
        return "block";
    }
}
